package viewPackage.menus;

import javax.swing.*;

import mainPackage.GFrame;
import mainPackage.GameMain;

import java.awt.*;
import java.awt.event.*;

public class MainMenuPanel extends JPanel {

	private GFrame gameFrame;
	
	public MainMenuPanel(GFrame mainFrame) {
		super();
		gameFrame = mainFrame;
		Graphics g = this.getGraphics();
		this.setBackground(Color.BLACK);
		MenuLabel gameTitle = new MenuLabel("Lost On Campus", 48);
		MenuLabel newGame = new MenuLabel("New Game", 20);
		MenuLabel options = new MenuLabel("Options", 20);
		MenuLabel exitGame = new MenuLabel("Exit Game", 20);
		
		newGame.addMouseListener(new JLabelMouse(newGame) {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				gameFrame.getContentPane().removeAll();
				gameFrame.getContentPane().add(new NewGamePanel(gameFrame), BorderLayout.CENTER);
				gameFrame.validate();
				gameFrame.repaint();
			}});
		
		options.addMouseListener(new JLabelMouse(options) {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				gameFrame.getContentPane().removeAll();
				gameFrame.getContentPane().add(new OptionsPanel(gameFrame), BorderLayout.CENTER);
				gameFrame.validate();
				gameFrame.repaint();
				
			}});
		
		exitGame.addMouseListener(new JLabelMouse(exitGame) {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				System.exit(0);				
			}});
		
		GridBagLayout gbl = new GridBagLayout();
		this.setLayout(gbl);
		
		Constraints Ctitle = new Constraints(0,0,1,1,true);
		Constraints Cnew = new Constraints(0,1,1,1,false);
		Constraints Coptions = new Constraints(0,2,1,1,false);
		Constraints Cexit = new Constraints(0,3,1,1,false);
		
		this.add(gameTitle, Ctitle);
		this.add(newGame, Cnew);
		this.add(options, Coptions);
		this.add(exitGame, Cexit);
		
	}


	protected void paintComponent(Graphics g) {
		//If I needed to draw stuff, it'd go here.
		super.paintComponent(g);
	}
	
}
